import com.taomeng.dao.UserDao;
import com.taomeng.util.Md5Util;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")

public class UpdatePassword {
    @Autowired
    private UserDao userDao;

    @Test
    public void test() {
        long id =9;
        String password = "test";

    /*    //加盐加密
        Md5Hash md5Hash1=new Md5Hash(password, Md5Util.SALT);
        System.out.println("加盐加密"+md5Hash1);
*/
        //加盐加密多次
        Md5Hash md5Hash2 = new Md5Hash(password, Md5Util.SALT, 10000);
        System.out.println("加盐加密10000次：" + md5Hash2);

        userDao.updatePasswordByUserId(id, md5Hash2.toString());
    }
}
